<!doctype html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
	<link rel="icon" href="https://static.nowcoder.com/images/logo_87_87.png"/>
	<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" crossorigin="anonymous">
	<link rel="stylesheet" th:href="@{/css/global.css}" />
	<link rel="stylesheet" th:href="@{/css/letter.css}" />
	<title>私信列表</title>
</head>
<body>
	<div class="nk-container">
		<!-- 头部 -->
		<header class="bg-dark sticky-top" th:replace="index::header">
		</header>

		<!-- 内容 -->
		<div class="main">
			<div class="container">
				<div class="position-relative">
					<!-- 选项 -->
					<ul class="nav nav-tabs mb-3">
						<li class="nav-item">
							<a class="nav-link position-relative active" th:href="@{/message/list}"><img th:src="@{/img/sixin.png}" width="18px" height="18px" class="up"> 私信<span class="badge badge-danger" th:text="${letterUnreadCount}" th:if="${letterUnreadCount!=0}">3</span></a>
						</li>
						<li class="nav-item">
							<a class="nav-link position-relative" th:href="@{/message/inform}"><img th:src="@{/img/tongzhi.png}" width="20px" height="20px">通知<span class="badge badge-danger" th:text="${informUnreadCount}" th:if="${informUnreadCount!=0}">27</span></a>
						</li>
					</ul>
					<button type="button" class="btn btn-primary btn-sm position-absolute rt-0" data-toggle="modal" data-target="#sendModal">发私信</button>
				</div>
				<!-- 弹出框 -->
				<div class="modal fade" id="sendModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
					<div class="modal-dialog modal-lg" role="document">
						<div class="modal-content" style="padding: 5px 25px;font-weight: lighter">
							<div class="modal-header">
								<h5 class="modal-title" style="font-weight: lighter" id="exampleModalLabel">发私信</h5>
								<button type="button" class="close" data-dismiss="modal" aria-label="Close">
									<span aria-hidden="true">&times;</span>
								</button>
							</div>
							<div class="modal-body">
								<form th:action="@{/message/send}" method="post">
									<div class="form-group">
										<label for="recipient-name" class="col-form-label">发给：</label>
										<input type="text" name="targetName" class="form-control" id="recipient-name" required>
									</div>
									<div class="form-group">
										<label for="message-text" class="col-form-label">内容：</label>
										<textarea class="form-control text-muted font-size-14" style="font-weight: lighter;border-radius: 5px" name="content" id="message-text" rows="10"></textarea>
									</div>
								</form>
							</div>
							<div class="modal-footer">
								<button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
								<button type="button" class="btn btn-primary" id="sendBtn">发送</button>
							</div>
						</div>
					</div>
				</div>		
				<!-- 提示框 -->
				<div class="modal fade" id="hintModal" tabindex="-1" role="dialog" aria-labelledby="hintModalLabel" aria-hidden="true">
					<div class="modal-dialog modal-lg" role="document">
						<div class="modal-content">
							<div class="modal-header">
								<h5 class="modal-title" id="hintModalLabel">提示</h5>
							</div>
							<div class="modal-body" id="hintBody" style="text-align: center">
								发送完毕!
							</div>
						</div>
					</div>
				</div>

				<div th:if="${messageList.size()==0}" style="padding-top: 50px;padding-bottom: 50px;text-align: center">
					<span class="text-muted font-size-14" style="font-weight: lighter">空空如也~</span><br/>
					<img th:src="@{/img/nothing.png}" >
				</div>

				<!-- 私信列表 -->
				<ul class="list-unstyled">
					<li class="media pb-3 pt-3 mb-3 border-bottom position-relative" th:each="messageMap:${messageList}">
						<span th:if="${messageMap.unreadCount!=0}" class="badge badge-danger" th:text="${messageMap.unreadCount}">3</span>
						<a th:href="@{|/user/profile/${messageMap.target.id}|}">
							<img th:src="${messageMap.target.headerUrl}" class="mr-4 rounded-circle user-header" alt="用户头像" >
						</a>
						<div class="media-body">
							<h6 class="mt-0 mb-3">
								<span class="text-success" th:utext="${messageMap.target.username}">落基山脉下的闲人</span>
								<span class="float-right text-muted font-size-12" th:text="${#dates.format(messageMap.message.createTime,'yyyy-MM-dd HH:mm:ss')}">2019-04-28 14:13:25</span>
							</h6>
							<div>
								<a th:href="@{|/message/detail/${messageMap.message.conversationId}/${messageMap.target.id}|}" th:utext="${messageMap.message.content}">米粉车, 你来吧!</a>
								<ul class="d-inline font-size-12 float-right">
									<li class="d-inline ml-2"><a th:href="@{|/message/detail/${messageMap.message.conversationId}/${messageMap.target.id}|}" class="text-primary">共[[${messageMap.letterCount}]]条会话</a></li>
								</ul>
							</div>
						</div>
					</li>
				</ul>
				<!-- 分页 -->
				<nav class="mt-5" th:replace="index::page">
				</nav>
			</div>
		</div>

		<!-- 尾部 -->
		<footer class="bg-dark" th:replace="index::footer">
		</footer>
	</div>

	<script src="https://code.jquery.com/jquery-3.3.1.min.js" crossorigin="anonymous"></script>
	<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" crossorigin="anonymous"></script>
	<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" crossorigin="anonymous"></script>
	<script th:src="@{/js/global.js}"></script>
	<script th:src="@{/js/letter.js}"></script>
</body>
</html>
